A high-level plotting API for the PyData ecosystem built on HoloViews.

The PyData ecosystem has a number of core Python data containers that allow users to work with a wide array of datatypes, including:

  • Pandas : DataFrame, Series (columnar/tabular data)
  • XArray : Dataset, DataArray (labelled multidimensional arrays)
  • Dask : DataFrame, Series (distributed/out of core arrays and columnar data)
  • Streamz : DataFrame(s), Series(s) (streaming columnar data)
  • Intake : DataSource (data catalogues)
  • GeoPandas : GeoDataFrame (geometry data)

Several of these libraries have the concept of a high-level plotting API that lets a user generate common plot types very easily. The native plotting APIs are generally built on Matplotlib , which provides a solid foundation, but means that users miss out the benefits of modern, interactive plotting libraries for the web like Bokeh and HoloViews .

hvPlot provides a high-level plotting API built on HoloViews that provides a general and consistent API for plotting data in all the abovementioned formats. hvPlot can integrate neatly with the individual libraries if an extension mechanism for the native plot APIs is offered, or it can be used as a standalone component. To get started jump straight into the Getting Started Guide and check out the current functionality in the User Guide.

Usage

hvPlot provides an alternative for the static plotting API provided by Pandas and other libraries, with an interactive Bokeh -based plotting API that supports panning, zooming, hovering, and clickable/selectable legends:

In [1]:
import pandas as pd, numpy as np
idx = pd.date_range('1/1/2000', periods=1000)
df  = pd.DataFrame(np.random.randn(1000, 4), index=idx, columns=list('ABCD')).cumsum()

import hvplot.pandas
df.hvplot()
Out[1]:

hvPlot works with multiple data sources, including the Intake data catalog, and supports a wide variety of plot types:

In [2]:
import intake, hvplot.intake

crime = intake.cat.us_crime
columns = ['Burglary rate', 'Larceny-theft rate', 'Robbery rate', 'Violent Crime rate']

crime.plot.violin(y=columns, group_label='Type of crime', value_label='Rate per 100k', invert=True)
Out[2]:

Unlike the default plotting, hvPlot output can easily be composed using * to overlay plots (or + to lay them out side by side):

In [3]:
crime.plot.bivariate(x='Burglary rate', y='Property crime rate', legend=False, width=500, height=400) * \
crime.plot.scatter(  x='Burglary rate', y='Property crime rate', color='black', size=15) +\
crime.plot.table(['Burglary rate', 'Property crime rate'], width=350, height=350)
Out[3]:

When used with streamz DataFrames, hvPlot can very easily plot streaming data to get a live updating plot:

In [4]:
from streamz.dataframe import Random
import hvplot.streamz

streaming_df = Random(freq='5ms') 

streaming_df.hvplot(backlog=100, height=400, width=500) +\
streaming_df.hvplot.hexbin(x='x', y='z', backlog=2000, height=400, width=500);

For multidimensional data not supported well by Pandas, you can use an XArray Dataset like this gridded data of North American air temperatures over time, which also demonstrates support for geographic projections :

In [5]:
import xarray as xr, hvplot.xarray, cartopy.crs as crs, geoviews as gv
from xarray.tutorial import load_dataset

air_ds = xr.tutorial.load_dataset('air_temperature')

air_ds.air.isel(time=slice(0, 3)).hvplot.quadmesh(
    'lon', 'lat', projection=crs.Orthographic(-90, 30), global_extent=True,
    width=600, height=540, cmap='viridis', rasterize=True, dynamic=False
) * gv.feature.coastline
Out[5]:

hvPlots will show widgets like the "Time" slider here whenever your data is indexed by dimensions that are not mapped onto the plot axes, allowing you to explore complex datasets much more easily than with the default plotting support.

hvPlot is designed to work well in and outside the Jupyter notebook, and thanks to built-in Datashader support scales easily to millions or even billions of datapoints:

The User Guide. shows more of what's available and how to use it.

Installation

hvPlot supports Python 2.7, 3.5, 3.6 and 3.7 on Linux, Windows, or Mac and can be installed with conda:

conda install -c pyviz hvplot

or with pip:

pip install hvplot

For JupyterLab support, the jupyterlab_pyviz extension is also required:

jupyter labextension install @pyviz/jupyterlab_pyviz

The Getting Started Guide has more details if you need them.